package com.ctshk.sapp.order.tour.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.order.tour.dto.SeriesOrderTouristVisaDetailDTO;
import com.ctshk.rpc.order.tour.dto.SeriesOrderTouristVisaListDTO;
import com.ctshk.rpc.order.tour.req.*;
import com.ctshk.rpc.order.tour.service.ISeriesOrderTouristVisaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 系列团游客签证记录 前端控制器
 * </p>
 *
 * @author 谭响
 * @since 2021-01-27
 */
@Api(value="签证", tags="签证")
@RestController
@RequestMapping("/series/order/tourist/visa")
public class SeriesOrderTouristVisaController extends BaseController {

    @DubboReference
    private ISeriesOrderTouristVisaService iSeriesOrderTouristVisaService;

//    @ApiOperation(value = "添加", notes = "添加")
//    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "添加", operDesc = "添加")
//    @PostMapping("/add")
//    public Result add(@RequestBody SeriesOrderTouristVisaAddReq req) {
//        req.setUserId(getCurrentUser(getRequest()).getId());
//        return iSeriesOrderTouristVisaService.add(req);
//    }

    @ApiOperation(value = "列表", notes = "列表（簽證管理）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "簽證管理", operDesc = "簽證管理")
    @PostMapping("/list")
    public Result<PageResponse<SeriesOrderTouristVisaListDTO>> list(@RequestBody @Valid SeriesOrderTouristVisaListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return Result.success(iSeriesOrderTouristVisaService.list(req));
    }

    @ApiOperation(value = "提交批量", notes = "提交批量（簽證管理-收齊證件提交後台）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "簽證管理-收齊證件提交後台", operDesc = "簽證管理-收齊證件提交後台")
    @PostMapping("/submit/batch")
    public Result submitBatch(@RequestBody @Valid SeriesOrderTouristVisaSubmitBatchReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.submitBatch(req);
    }

    @ApiOperation(value = "送签批量", notes = "送签批量（旅客名單-更多-送签）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "旅客名單-更多-送签", operDesc = "旅客名單-更多-送签")
    @PostMapping("/send/batch")
    public Result sendBatch(@RequestBody @Valid SeriesOrderTouristVisaSendBatchReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.sendBatch(req);
    }

    @ApiOperation(value = "登记批量", notes = "登记批量（旅客名單-更多-登记）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "旅客名單-更多-登记", operDesc = "旅客名單-更多-登记")
    @PostMapping("/enter/batch")
    public Result enterBatch(@RequestBody @Valid SeriesOrderTouristVisaEnterBatchReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.enterBatch(req);
    }

    @ApiOperation(value = "补充批量", notes = "补充批量（簽證管理-提交後補資料）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "簽證管理-提交後補資料", operDesc = "簽證管理-提交後補資料")
    @PostMapping("/supplement/batch")
    public Result supplementBatch(@RequestBody @Valid SeriesOrderTouristVisaSupplementBatchReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.supplementBatch(req);
    }

    @ApiOperation(value = "出签批量", notes = "出签批量（旅客名單-更多-出签成功/出签失败）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "名單-更多-出签成功/出签失败", operDesc = "名單-更多-出签成功/出签失败")
    @PostMapping("/out/batch")
    public Result outBatch(@RequestBody @Valid SeriesOrderTouristVisaOutBatchReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.outBatch(req);
    }

    @ApiOperation(value = "详情", notes = "详情（簽證管理-查看）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "簽證管理-查看", operDesc = "簽證管理-查看")
    @PostMapping("/detail")
    public Result<SeriesOrderTouristVisaDetailDTO> detail(@RequestBody @Valid SeriesOrderTouristVisaDetailReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return iSeriesOrderTouristVisaService.detail(req);
    }
}
